package com.dailyblue.java.spring.boot.simple.example.controller;

import com.dailyblue.java.spring.boot.simple.example.bean.Classes;
import com.dailyblue.java.spring.boot.simple.example.bean.Student;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

@RequestMapping("/first")
@Controller
public class FirstController {
    @RequestMapping("/a")
    public String a() {
        System.out.println("FirstController`a method!");
        return "index";
    }

    // 通过@Value获取配置文件的信息
    @Value("${name}")
    private String name;
    @Value("${age}")
    private Integer age;
    @Value("${birthday}")
    private String birthday;

    @ResponseBody
    @RequestMapping("/b")
    public String b() {
        System.out.println("This is FirstControlelr`b method!params:" + name + "," + age + "," + birthday);
        return "This is FirstControlelr`b method!params:" + name + "," + age + "," + birthday;
    }

    @Value("${user1.name}")
    private String name1;
    @Value("${user2.name}")
    private String name2;

    @ResponseBody
    @RequestMapping("/c")
    public String c() {
        System.out.println("This is FirstController`c method!params:" + name1 + "," + name2);
        return "This is FirstController`c method!params:" + name1 + "," + name2;
    }

    @Resource
    private Classes classes;
    @ResponseBody
    @RequestMapping("/d")
    public Classes d(){
        return classes;
    }
    @Resource
    private Student student;
    @ResponseBody
    @RequestMapping("/e")
    public Student e(){
        return student;
    }
}
